package com.cg.big_event.entity;
import com.cg.big_event.anno.State;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.groups.Default;
import java.time.LocalDateTime;
import java.util.Date;
import java.io.Serializable;
/**
 * (Article)实体类
 *
 * &#064;author李浩月
 * @since 2024-11-19 22:39:09
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Article implements Serializable {
    private static final long serialVersionUID = 719366133982201014L;
    /**
     * ID
     */
    @NotNull(groups = Update.class)
    private String id;
    /**
     * 文章标题
     */
    @NotEmpty
    @Pattern (regexp = "^.{1,10}$",message = "文章标题长度在1-10之间")
    private String title;
    /**
     * 文章内容
     */
    @NotEmpty
    private String content;
    /**
     * 文章封面
     */
    @NotEmpty
    @URL
    private String coverImg;
    /**
     * 文章状态: 只能是[已发布] 或者 [草稿]
     */
    @State
    private String state;
    /**
     * 文章分类ID
     */
    @NotNull(groups = Add.class)
    private String categoryId;
    /**
     * 创建人ID
     */
    private String createUser;
    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    /**
     * 修改时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;
    // 分组校验
    public interface Add extends Default {};
    public interface Update extends Default {};

}

